Skip to main content

Wandb integration

WandB calls in the training process:

In the compute-msi app, we are logged into the deven-gqc account. We have been logged into the account through the command line as verified in the pictures below:
cmdlinelogin cmdlineverify In fastai_multi_label_v3_generic.py there are 15 wandb calls that are made. This page explains what each of the calls do.

  1. wandb.init(project=f'cctv-{settings.UTILITY}-defect-multilabel', name=run_name, entity='lence_ubc')
  2. wandb.init(project=f'cctv-{settings.UTILITY}-multilabel', name=run_name, entity='lence_ubc')

The wandb init method is used to spawn a background process to log data related to the run. The arguments of the init method specify the location in the WandB website where the logs related to the run are stored.

  1. learn = vision_learner( dls, resnet50, pretrained=settings.PRETRAINED, loss_func=loss, metrics=[ partial(accuracy_multi, thresh=threshold), f1score_multi_avg, f1score_multi, f2score_multi ], cbs=[WandbCallback(), SaveModelCallback(every_epoch=2, with_opt=True)])

WandbCallback() is a fastai class that logs data to wandb. By default, WandbCallBack logs model predictions on a wandb table and uses 36 samples to log predictions. Over here, it is used in conjunction with SaveModelCallBack() to save the best model.

  1. learn = vision_learner( dls, custom_loaded_model, pretrained=settings.PRETRAINED, loss_func=loss, metrics=[ partial(accuracy_multi, thresh=threshold), f1score_multi_avg, f1score_multi, f2score_multi ], cbs=[WandbCallback(), SaveModelCallback(every_epoch=2, with_opt=True)])

WandbCallback() is a fastai class that logs data to wandb. By default, WandbCallBack logs model predictions on a wandb table and uses 36 samples to log predictions. Over here, it is used in conjunction with SaveModelCallBack() to save the best model.

  1. wandb.log({'learning rate': settings.LEARNING_RATE})

This call is used to log the learning rate of the run on the WandB wesbite.

  1. wandb.log({f'F1 validation {x}': f1_x})
  2. wandb.log({f'F2 validation {x}': f2_x})
  3. wandb.log({f'F1 validation normal': f1_normal})
  4. wandb.log({'F1 validation average': f1_avg})
  5. wandb.log({'F2 validation average': f2_avg})
  6. wandb.log({'F1 validation average no ND': f1_avg})
  7. wandb.log({'F2 validation average no ND': f2_avg})

These wandb calls are made to log the corresponsing metrics after calculating them.

  1. wandb.finish()

The wandb.finish() command is used to end the run and log data into the wandb project.